package ift605.tp3.b.resolvers;

import ift605.tp3.utils.equations.ConstantEq;
import ift605.tp3.utils.equations.IEquation;
import ift605.tp3.utils.equations.PowEq;
import ift605.tp3.utils.equations.VariableEq;

public class PowResolverAgent extends AbstractResolverAgent
{
    private static final long serialVersionUID = 1L;
    
    @Override
    protected IEquation derive(IEquation eq)
    {
        if (eq instanceof VariableEq)
        {
            final VariableEq equation = (VariableEq) eq;
            return new ConstantEq(equation.getValue());
        }
        
        if (eq instanceof PowEq)
        {
            final PowEq equation = (PowEq) eq;
            return new PowEq(equation.getExponent() * equation.getCoefficient(), equation.getExponent() - 1);
        }
        return null;
    }
    
    @Override
    protected String getType()
    {
        return PowEq.class.getName();
    }
}
